package com.ruoyi.instrument.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SNUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.instrument.mapper.InstrumentDataMapper;
import com.ruoyi.instrument.domain.InstrumentData;
import com.ruoyi.instrument.service.IInstrumentDataService;
import com.ruoyi.common.core.controller.BaseController;
/**
 * 仪器Service业务层处理
 * 
 * @author weihanqiang
 * @date 2025-04-18
 */
@Service
public class InstrumentDataServiceImpl implements IInstrumentDataService 
{
    @Autowired
    private InstrumentDataMapper instrumentDataMapper;

    @Autowired
    private SNUtil snUtil;

    /**
     * 查询仪器
     * 
     * @param instrumentId 仪器主键
     * @return 仪器
     */
    @Override
    public InstrumentData selectInstrumentDataByInstrumentId(Long instrumentId)
    {
        return instrumentDataMapper.selectInstrumentDataByInstrumentId(instrumentId);
    }

    /**
     * 查询仪器列表
     * 
     * @param instrumentData 仪器
     * @return 仪器
     */
    @Override
    public List<InstrumentData> selectInstrumentDataList(InstrumentData instrumentData)
    {
        return instrumentDataMapper.selectInstrumentDataList(instrumentData);
    }

    /**
     * 新增仪器
     * 
     * @param instrumentData 仪器
     * @return 结果
     */
    @Override
    public int insertInstrumentData(InstrumentData instrumentData)
    {
        String insNo = snUtil.generateSN("instrument_data", "instrument_no", "yyyyMMdd", "INS", 4);
        instrumentData.setInstrumentNo(insNo);
        instrumentData.setCreateTime(DateUtils.getNowDate());
        return instrumentDataMapper.insertInstrumentData(instrumentData);
    }

    /**
     * 修改仪器
     * 
     * @param instrumentData 仪器
     * @return 结果
     */
    @Override
    public int updateInstrumentData(InstrumentData instrumentData)
    {
        return instrumentDataMapper.updateInstrumentData(instrumentData);
    }

    /**
     * 批量删除仪器
     * 
     * @param instrumentIds 需要删除的仪器主键
     * @return 结果
     */
    @Override
    public int deleteInstrumentDataByInstrumentIds(Long[] instrumentIds)
    {
        return instrumentDataMapper.deleteInstrumentDataByInstrumentIds(instrumentIds);
    }

    /**
     * 删除仪器信息
     * 
     * @param instrumentId 仪器主键
     * @return 结果
     */
    @Override
    public int deleteInstrumentDataByInstrumentId(Long instrumentId)
    {
        return instrumentDataMapper.deleteInstrumentDataByInstrumentId(instrumentId);
    }
}
